home *** CD-ROM | disk | FTP | other *** search
- {{{ comments
- ; This macro simulates tab-keys (using spaces to go to next position!)
- ; you can define 4 tab-width in the following way:
- ; tab-width /tab-count: the first tab-count jumps use tab-width
- ; tab-width-1/tab-count-1: the next tab-count-1 jumps use tab-width-1
- ; tab-width-2/tab-count-2: the next tab-count-2 jumps use tab-width-2
- ; tab-width-3: this is the width for all following jumps
- ; negative values for counts have the effect, that the corresponding
- ; width-values are use for all following jumps.
- ;
- ; for example:
- ;
- ;* the startup-values are:
- ; tab-width 1
- ; tab-count -1
- ; these values let tab have the same effect as space
- ;
- ;* given the values:
- ; tab-width=2 tab-count=1
- ; tab-width-1=3 tab-count-1=2
- ; tab-width-2=4 tab-count-2=2
- ; tab-width-3=5
- ;
- ; the resulting tab-positions are:
- ;
- ; a b c d e f g h i j k l m
- ; ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
- ; | | | | | | all following jumps use tab-width-3
- ; | | | | | |
- ; | | | | tab-width-2-jumps
- ; | | | |
- ; | | tab-width-1-jumps
- ; | |
- ; | tab-width-jump
- ; |
- ; first character in line
- }}}
- @if-using not(TAB)
- @use (TAB)
- {{{ vars
- ( defvar
- ( tab-width ; first tab-step
- tab-count ; number of usages for ^, <0 -> always
- tab-width-1 ; second tab-step
- tab-count-1 ; number of usages of step 2
- tab-width-2 ; third tab-step
- tab-count-2 ; number of usages of step 3
- tab-width-3 ; last tab-step
- tab-missing-spaces ; help-counter
- )
- )
- }}}
- {{{ go_to_next_tab
- (deffun go_to_next_tab (
- if in-prompt ( return-from-macro ) fi
- {{{ maybe initialise the counter for tab-width
- if <=(tab-width 0) ( set tab-width 0 ) fi
- }}}
- if =(tab-width 0)
- ( insert-ascii 9 return-from-macro )
- fi
- {{{ tab-missing-spaces = #missing `` ''
- set tab-missing-spaces -(1 +(store-pos set-space-enter))
- local (tab-count tab-count-1 tab-count-2) (
- do (
- case
- ( tab-count
- ( set tab-missing-spaces +(tab-missing-spaces tab-width )
- set tab-count +(tab-count -1)
- )
- )
- ( tab-count-1
- ( set tab-missing-spaces +(tab-missing-spaces tab-width-1)
- set tab-count-1 +(tab-count-1 -1)
- )
- )
- ( tab-count-2
- ( set tab-missing-spaces +(tab-missing-spaces tab-width-2)
- set tab-count-2 +(tab-count-2 -1)
- )
- )
- default
- (set tab-missing-spaces +(tab-missing-spaces tab-width-3))
- esac
- ) while <=(tab-missing-spaces 0)
- )
- }}}
- {{{ insert the spaces
- do
- ( " ;
- set tab-missing-spaces +(tab-missing-spaces -1)
- )
- while <>(tab-missing-spaces 0)
- }}}
- ))
- }}}
- {{{ define-tab
- (deffun define-tab (
- if in-prompt ( return-from-macro ) fi
- prompt-counter tab-width (M_TABSIZE " "? )
- set tab-count -1
- ))
- }}}
- {{{ undeclare
- ( undeclare ( tab-missing-spaces ) )
- }}}
- @fi
-